import apiClient from './apiClient'

/**
 * 统计报表API服务
 */
export const statisticsApi = {
  /**
   * 获取实时统计仪表盘
   */
  getDashboardStats() {
    return apiClient.get('/api/search-reports/dashboard-stats')
  },

  /**
   * 获取团队绩效报表
   */
  getTeamPerformanceReport() {
    return apiClient.get('/api/search-reports/team-performance')
  },

  /**
   * 获取SLA统计报表
   */
  getSLAStatisticsReport() {
    return apiClient.get('/api/search-reports/sla-statistics')
  },

  /**
   * 获取趋势图表数据
   */
  getTrendChartData() {
    return apiClient.get('/api/search-reports/trend-charts')
  },

  /**
   * 获取综合统计报表
   */
  getComprehensiveReport() {
    return apiClient.get('/api/search-reports/comprehensive-report')
  },

  /**
   * 导出统计报表为PDF
   */
  exportReportPdf(reportType) {
    return apiClient.get(`/api/search-reports/export-report-pdf?reportType=${reportType}`)
  },

  /**
   * 清除统计缓存
   */
  clearStatisticsCache() {
    return apiClient.post('/api/search-reports/clear-cache')
  },

  /**
   * 刷新统计数据
   */
  refreshStatistics() {
    return apiClient.post('/api/search-reports/refresh-statistics')
  }
}

/**
 * 报表综合API服务（包含统计和订阅功能）
 */
export const searchAndReportApi = {
  ...statisticsApi,

  /**
   * 获取报表订阅
   */
  getReportSubscriptions(userId) {
    return apiClient.get(`/api/search-reports/subscriptions/${userId}`)
  },

  /**
   * 创建报表订阅
   */
  createReportSubscription(subscription) {
    return apiClient.post('/api/search-reports/subscriptions', subscription)
  },

  /**
   * 更新报表订阅
   */
  updateReportSubscription(subscriptionId, subscription) {
    return apiClient.put(`/api/search-reports/subscriptions/${subscriptionId}`, subscription)
  },

  /**
   * 删除报表订阅
   */
  deleteReportSubscription(subscriptionId) {
    return apiClient.delete(`/api/search-reports/subscriptions/${subscriptionId}`)
  }
}

export default {
  statisticsApi,
  searchAndReportApi
}
